package cn.yuanqiao.web.controller.archive.feedbackEvaluation;

import cn.yuanqiao.archive.feedbackEvaluation.domain.FeedbackEvaluation;
import cn.yuanqiao.archive.feedbackEvaluation.service.IFeedbackEvaluationService;

import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.core.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.core.page.TableDataInfo;
import cn.yuanqiao.common.enums.BusinessType;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 反馈评价Controller
 *
 * @author xy
 * @date 2024-10-11
 */
@RestController
@RequestMapping("/archive/evaluation")
public class FeedbackEvaluationController extends BaseController
{
    @Autowired
    private IFeedbackEvaluationService feedbackEvaluationService;

    /**
     * 查询反馈评价列表
     */
   // @RequiresPermissions("archive:evaluation:list")
    @GetMapping("/list")
    public TableDataInfo list(FeedbackEvaluation feedbackEvaluation)
    {
        startPage();
        List<FeedbackEvaluation> list = feedbackEvaluationService.selectFeedbackEvaluationList(feedbackEvaluation);
        return getDataTable(list);
    }

    /**
     * 导出反馈评价列表
     */
   // @RequiresPermissions("archive:evaluation:export")
    @Log(title = "反馈评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FeedbackEvaluation feedbackEvaluation)
    {
        List<FeedbackEvaluation> list = feedbackEvaluationService.selectFeedbackEvaluationList(feedbackEvaluation);
        ExcelUtil<FeedbackEvaluation> util = new ExcelUtil<FeedbackEvaluation>(FeedbackEvaluation.class);
        util.exportExcel(response, list, "反馈评价数据");
    }

    /**
     * 获取反馈评价详细信息
     */
   // @RequiresPermissions("archive:evaluation:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(feedbackEvaluationService.selectFeedbackEvaluationById(id));
    }

    @GetMapping(value = "/archiveBorrow/{id}")
    public AjaxResult getArchiveBorrowByBorrowId(@PathVariable("id") Long id)
    {
        return success(feedbackEvaluationService.selectArchiveBorrowByBorrowId(id));
    }

    /**
     * 新增反馈评价
     */
    //@RequiresPermissions("archive:evaluation:add")
    @Log(title = "反馈评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeedbackEvaluation feedbackEvaluation)
    {
        return toAjax(feedbackEvaluationService.insertFeedbackEvaluation(feedbackEvaluation));
    }

    /**
     * 修改反馈评价
     */
  //  @RequiresPermissions("archive:evaluation:edit")
    @Log(title = "反馈评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeedbackEvaluation feedbackEvaluation)
    {
        return toAjax(feedbackEvaluationService.updateFeedbackEvaluation(feedbackEvaluation));
    }

    /**
     * 删除反馈评价
     */
   // @RequiresPermissions("archive:evaluation:remove")
    @Log(title = "反馈评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(feedbackEvaluationService.deleteFeedbackEvaluationByIds(ids));
    }
}
